package com.lancoo.cvas.mapper;

import com.lancoo.cvas.config.MybatisRedisCache;
import com.lancoo.cvas.entity.Schedule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lancoo.cvas.entity.ViewSchedule;
import com.lancoo.cvas.pojo.dto.ArrangeScheduleDto;
import com.lancoo.cvas.pojo.dto.ScheduleDto;
import com.lancoo.cvas.pojo.dto.SyncScheduleDto;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * 课表
 *
 * @author liufeng
 * @email 1037383243@qq.com
 * @date 2023-12-04 11:54:00
 */
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface ScheduleMapper extends BaseMapper<Schedule> {


    /**
     * 根据教学班id获取多个教学班教学安排
     *
     * @param taskId
     * @param teachingClassIds
     * @return
     */
    List<ScheduleDto> getAllScheduleByTeachingClassIds(Integer taskId, List<Long> teachingClassIds);

    /**
     * 根据教学班id获取多个教学班教学安排
     *
     * @param taskId
     * @param teachingClassIds
     * @return
     */
    List<ScheduleDto> getScheduleByTeachingClassIds(Integer taskId, List<Long> teachingClassIds, Long roomId);

    /**
     * @param taskIds:
     * @param campusId:
     * @param isLocked:
     * @param roomType:
     * @Description: 根据任务id获取全部课表
     * @Author: liufeng
     * @Date: 2023/12/12 16:33
     * @return:
     */
    List<ArrangeScheduleDto> getScheduleLockedByIds(@Param("taskIds") List<Integer> taskIds, @Param("campusId") String campusId, @Param("isLocked") Integer isLocked, @Param("roomType") Integer roomType);

    /**
     * 获取锁定的教学班课表
     *
     * @param taskId
     * @param campusId
     * @return
     */
    List<ArrangeScheduleDto> getScheduleLocked(@Param("taskId") Integer taskId, @Param("campusId") String campusId, @Param("isLocked") Integer isLocked, @Param("roomType") Integer roomType);

    List<ArrangeScheduleDto> getScheduleListByTeachingClassIds(Integer taskId, String campusId, List<Long> tcIds);


    int addBatch(@Param("scheduleCollection") Collection<Schedule> scheduleCollection);

    /**
     * 根据教学班id获取多个教学班教学安排 roomid
     *
     * @param taskId
     * @param teachingClassIds
     * @param roomId
     * @return
     */
    List<ScheduleDto> getScheduleByTeachingClassIdsAndRoomId(@Param("taskId") Integer taskId, @Param("teachingClassIds") List<Long> teachingClassIds, @Param("roomId") Long roomId);

    List<Long> getRoomTeachingClassByTaskId(List<Integer> taskIds, Long roomId, int deleted);

    List<ViewSchedule> getAllSchedule(List<Integer> taskIds);

    List<SyncScheduleDto> syncScheduleDto(Integer taskId);

    Integer getCount(Integer taskId);

    Long removeSchedule(Long roomId, List<Schedule> scheduleList);

    List<ScheduleDto> getAllScheduleByTeachingClassIdAndHourType(Long teachingClassId, Integer hourType);

    List<ViewSchedule> getTeacherScheduledTimeCodes(List<Integer> taskIds, String teacherId);

    List<Schedule> selectBuTaskId(Integer taskId, int deleted);

    Integer checkHasSchedule(Integer taskId, String schoolId, String term, int deleted);

    void subSchedule(List<Schedule> list);

    void reAutoArrange(Integer taskId);

    void deleteScheduleByClassAndType(List<Schedule> schedules);

}
